﻿	/*
MiniAccess支持的实体属性的映射方式有如下几种：
<entity name="" table="" command-type="" insert="" 
              delete="" multiple-delete="" update="" multiple-update="" fetch="" search="" >
	<primary-key name="" column="" update="true|flase" insert="true|false"/>
	<property name=""    column="" update="true|flase" insert="true|false"/>
	<many-to-one name="" column="" update="true|flase" insert="true|false"/>
	<one-to-one name="" column="" update="true|flase" insert="true|false"/>
</entity>
下面是根据数据生成的基本映射框架，可以复制到程序集下“程序集名字.mdm.xml”中修改使用，比如修改程序集和连接字符串的设置等。
<?xml version="1.0" encoding="utf-8" ?>
<miniaccess-mapping xmlns="urn:miniacess-mapping-1.0" >
	<access-type name="System.Data.SqlClient">
		<provider name="HostServer" entity-namespace="Ruandao.HostServer.SqlEntityAccess" is-debug="true">
			<entity name="DatabaseEntity" table="Database" ></entity>
			<entity name="DomainEntity" table="Domain" ></entity>
			<entity name="FileStorageEntity" table="FileStorage" ></entity>
			<entity name="SiteEntity" table="Site" ></entity>
			<entity name="SiteWareEntity" table="SiteWare" ></entity>
		</provider>
	</access-type>
</miniaccess-mapping>
*/
//-----------------------------------------------------------------
// 该代码文件由CodeSmith的MiniAccess.cst模板创建，运行时需要MiniAccess程序集的支持。 
// 创建者  :  WuGui.Yang
// 创建时间:  2012年9月12日
//-----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Configuration;

/// <summary>
/// 包含存取Foundation数据库的Access工具类和所有Entity实体类。
/// <br/>这些类均实现为Partial方式，使用时可以在单独的文件中扩展这些类的成员。
/// </summary>
namespace Ruandao.HostServer.SqlEntityAccess
{
    using Ruandao.MiniAccess;
	using Ruandao.MiniAccess.SqlServer;

    /// <summary>
	/// 该类封装了SqlServerAccess针对具体某个数据库的IAccess的一个实例，提供了存取Foundation数据库的工具方法。
    /// <br/>该类使用了单例模式，没有公开构造方法，只能通过GetInstance()获取类的实例。
    /// </summary>
	public sealed partial class HostServerAccess : SqlServerAccess
	{
        private HostServerAccess(string connstring)
            : base( Assembly.GetAssembly(typeof(HostServerAccess)),
                    "HostServer",
                    connstring)
        { }
	}
    

	/// <summary>
	/// Table [Database] MiniAccess Entity Class 
	/// </summary>
	public partial class DatabaseEntity : EntityBase< DatabaseEntity >
	{
		#region Construct

		public DatabaseEntity():base(HostServerAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int databaseId = 0;
		public int DatabaseId
		{
			get { return this.databaseId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.databaseId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("databaseId", this.databaseId);
                    this.databaseId = value;
                }
			}
		}

		private string dbType = String.Empty;
		public string DbType
		{
			get { return this.dbType; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.dbType != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("dbType", this.dbType);
                    this.dbType = value;
                }
			}
		}

		private string instance = String.Empty;
		public string Instance
		{
			get { return this.instance; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.instance != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("instance", this.instance);
                    this.instance = value;
                }
			}
		}

		private string connection = String.Empty;
		public string Connection
		{
			get { return this.connection; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.connection != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("connection", this.connection);
                    this.connection = value;
                }
			}
		}

		private string accessType = String.Empty;
		public string AccessType
		{
			get { return this.accessType; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.accessType != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("accessType", this.accessType);
                    this.accessType = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< SiteEntity > GetSiteEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< SiteEntity >("WHERE DatabaseId="+databaseId);
		}
		public IList< SiteWareEntity > GetSiteWareEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< SiteWareEntity >("WHERE DatabaseId="+databaseId);
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static DatabaseEntity Fetch(int databaseId)
		{
            return HostServerAccess.GetInstance().FetechEntity< DatabaseEntity >(databaseId);
		}
		public static int Delete(int databaseId)
		{
            return HostServerAccess.GetInstance().DeleteEntity< DatabaseEntity >(databaseId);
		}
		
		
        // 获取表中的所有记录。
		public static IList< DatabaseEntity > GetAllEntities()
		{
            return HostServerAccess.GetInstance().SearchEntities< DatabaseEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< DatabaseEntity > SearchEntities(string condition)
		{
            return HostServerAccess.GetInstance().SearchEntities< DatabaseEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [Domain] MiniAccess Entity Class 
	/// </summary>
	public partial class DomainEntity : EntityBase< DomainEntity >
	{
		#region Construct

		public DomainEntity():base(HostServerAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int domainId = 0;
		public int DomainId
		{
			get { return this.domainId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.domainId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("domainId", this.domainId);
                    this.domainId = value;
                }
			}
		}

		private string domainName = String.Empty;
		public string DomainName
		{
			get { return this.domainName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.domainName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("domainName", this.domainName);
                    this.domainName = value;
                }
			}
		}

		private Guid siteGuid = Guid.Empty;
		public Guid SiteGuid
		{
			get { return this.siteGuid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteGuid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteGuid", this.siteGuid);
                    this.siteGuid = value;
                }
			}
		}

		private string domainType = String.Empty;
		public string DomainType
		{
			get { return this.domainType; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.domainType != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("domainType", this.domainType);
                    this.domainType = value;
                }
			}
		}

		private string specialPath = String.Empty;
		public string SpecialPath
		{
			get { return this.specialPath; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.specialPath != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("specialPath", this.specialPath);
                    this.specialPath = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		public SiteEntity GetSite()
		{
			return HostServerAccess.GetInstance().FetechEntity< SiteEntity >(siteGuid);
		}
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static DomainEntity Fetch(int domainId)
		{
            return HostServerAccess.GetInstance().FetechEntity< DomainEntity >(domainId);
		}
		public static int Delete(int domainId)
		{
            return HostServerAccess.GetInstance().DeleteEntity< DomainEntity >(domainId);
		}
		
        // 根据唯一索引（UIX_SiteDomainName）查找和删除实体的函数。
		public static DomainEntity FetchByUIX_SiteDomainName(string domainName)
		{
			string condition = "WHERE " + 
				"DomainName='" + domainName.ToString() + "'";
            return HostServerAccess.GetInstance().FindEntity< DomainEntity >("WHERE " + 
				"DomainName='" + domainName.ToString() + "'");
		} 
		public static int DeleteByUIX_SiteDomainName(string domainName)
		{
			string condition = "WHERE " + 
				"DomainName='" + domainName.ToString() + "'";
            return HostServerAccess.GetInstance().DeleteEntities< DomainEntity >("WHERE " + 
				"DomainName='" + domainName.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< DomainEntity > GetAllEntities()
		{
            return HostServerAccess.GetInstance().SearchEntities< DomainEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< DomainEntity > SearchEntities(string condition)
		{
            return HostServerAccess.GetInstance().SearchEntities< DomainEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [FileStorage] MiniAccess Entity Class 
	/// </summary>
	public partial class FileStorageEntity : EntityBase< FileStorageEntity >
	{
		#region Construct

		public FileStorageEntity():base(HostServerAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int fileStorageId = 0;
		public int FileStorageId
		{
			get { return this.fileStorageId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.fileStorageId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("fileStorageId", this.fileStorageId);
                    this.fileStorageId = value;
                }
			}
		}

		private string storageType = String.Empty;
		public string StorageType
		{
			get { return this.storageType; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.storageType != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("storageType", this.storageType);
                    this.storageType = value;
                }
			}
		}

		private string location = String.Empty;
		public string Location
		{
			get { return this.location; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.location != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("location", this.location);
                    this.location = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< SiteEntity > GetSiteEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< SiteEntity >("WHERE FileStorageId="+fileStorageId);
		}
		public IList< SiteWareEntity > GetSiteWareEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< SiteWareEntity >("WHERE FileStorageId="+fileStorageId);
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static FileStorageEntity Fetch(int fileStorageId)
		{
            return HostServerAccess.GetInstance().FetechEntity< FileStorageEntity >(fileStorageId);
		}
		public static int Delete(int fileStorageId)
		{
            return HostServerAccess.GetInstance().DeleteEntity< FileStorageEntity >(fileStorageId);
		}
		
		
        // 获取表中的所有记录。
		public static IList< FileStorageEntity > GetAllEntities()
		{
            return HostServerAccess.GetInstance().SearchEntities< FileStorageEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< FileStorageEntity > SearchEntities(string condition)
		{
            return HostServerAccess.GetInstance().SearchEntities< FileStorageEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [Site] MiniAccess Entity Class 
	/// </summary>
	public partial class SiteEntity : EntityBase< SiteEntity >
	{
		#region Construct

		public SiteEntity():base(HostServerAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private Guid siteGuid = Guid.Empty;
		public Guid SiteGuid
		{
			get { return this.siteGuid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteGuid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteGuid", this.siteGuid);
                    this.siteGuid = value;
                }
			}
		}

		private string siteName = String.Empty;
		public string SiteName
		{
			get { return this.siteName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteName", this.siteName);
                    this.siteName = value;
                }
			}
		}

		private string title = String.Empty;
		public string Title
		{
			get { return this.title; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.title != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("title", this.title);
                    this.title = value;
                }
			}
		}

		private string description = String.Empty;
		public string Description
		{
			get { return this.description; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.description != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("description", this.description);
                    this.description = value;
                }
			}
		}

		private Guid ownerGuid = Guid.Empty;
		public Guid OwnerGuid
		{
			get { return this.ownerGuid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.ownerGuid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("ownerGuid", this.ownerGuid);
                    this.ownerGuid = value;
                }
			}
		}

		private string userLevel = String.Empty;
		public string UserLevel
		{
			get { return this.userLevel; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.userLevel != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("userLevel", this.userLevel);
                    this.userLevel = value;
                }
			}
		}

		private DateTime createDate = DateTime.MaxValue;
		public DateTime CreateDate
		{
			get { return this.createDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.createDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("createDate", this.createDate);
                    this.createDate = value;
                }
			}
		}

		private int databaseId = 0;
		public int DatabaseId
		{
			get { return this.databaseId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.databaseId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("databaseId", this.databaseId);
                    this.databaseId = value;
                }
			}
		}

		private string siteDbName = String.Empty;
		public string SiteDbName
		{
			get { return this.siteDbName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteDbName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteDbName", this.siteDbName);
                    this.siteDbName = value;
                }
			}
		}

		private int fileStorageId = 0;
		public int FileStorageId
		{
			get { return this.fileStorageId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.fileStorageId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("fileStorageId", this.fileStorageId);
                    this.fileStorageId = value;
                }
			}
		}

		private bool containsAccount;
		public bool ContainsAccount
		{
			get { return this.containsAccount; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.containsAccount != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("containsAccount", this.containsAccount);
                    this.containsAccount = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< DomainEntity > GetDomainEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< DomainEntity >("WHERE SiteGuid='"+siteGuid+"'");
		}
		public IList< SiteWareEntity > GetSiteWareEntities()
		{
			return HostServerAccess.GetInstance().SearchEntities< SiteWareEntity >("WHERE SiteGuid='"+siteGuid+"'");
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		public DatabaseEntity GetDatabase()
		{
			return HostServerAccess.GetInstance().FetechEntity< DatabaseEntity >(databaseId);
		}
		public FileStorageEntity GetFileStorage()
		{
			return HostServerAccess.GetInstance().FetechEntity< FileStorageEntity >(fileStorageId);
		}
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static SiteEntity Fetch(Guid siteGuid)
		{
            return HostServerAccess.GetInstance().FetechEntity< SiteEntity >(siteGuid);
		}
		public static int Delete(Guid siteGuid)
		{
            return HostServerAccess.GetInstance().DeleteEntity< SiteEntity >(siteGuid);
		}
		
        // 根据唯一索引（UIX_SiteName）查找和删除实体的函数。
		public static SiteEntity FetchByUIX_SiteName(string siteName)
		{
			string condition = "WHERE " + 
				"SiteName='" + siteName.ToString() + "'";
            return HostServerAccess.GetInstance().FindEntity< SiteEntity >("WHERE " + 
				"SiteName='" + siteName.ToString() + "'");
		} 
		public static int DeleteByUIX_SiteName(string siteName)
		{
			string condition = "WHERE " + 
				"SiteName='" + siteName.ToString() + "'";
            return HostServerAccess.GetInstance().DeleteEntities< SiteEntity >("WHERE " + 
				"SiteName='" + siteName.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< SiteEntity > GetAllEntities()
		{
            return HostServerAccess.GetInstance().SearchEntities< SiteEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< SiteEntity > SearchEntities(string condition)
		{
            return HostServerAccess.GetInstance().SearchEntities< SiteEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [SiteWare] MiniAccess Entity Class 
	/// </summary>
	public partial class SiteWareEntity : EntityBase< SiteWareEntity >
	{
		#region Construct

		public SiteWareEntity():base(HostServerAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int siteWareId = 0;
		public int SiteWareId
		{
			get { return this.siteWareId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteWareId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteWareId", this.siteWareId);
                    this.siteWareId = value;
                }
			}
		}

		private Guid siteGuid = Guid.Empty;
		public Guid SiteGuid
		{
			get { return this.siteGuid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.siteGuid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("siteGuid", this.siteGuid);
                    this.siteGuid = value;
                }
			}
		}

		private string wareName = String.Empty;
		public string WareName
		{
			get { return this.wareName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.wareName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("wareName", this.wareName);
                    this.wareName = value;
                }
			}
		}

		private DateTime createDate = DateTime.MaxValue;
		public DateTime CreateDate
		{
			get { return this.createDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.createDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("createDate", this.createDate);
                    this.createDate = value;
                }
			}
		}

		private int? databaseId = 0;
		public int? DatabaseId
		{
			get { return this.databaseId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.databaseId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("databaseId", this.databaseId);
                    this.databaseId = value;
                }
			}
		}

		private string wareDbName = String.Empty;
		public string WareDbName
		{
			get { return this.wareDbName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.wareDbName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("wareDbName", this.wareDbName);
                    this.wareDbName = value;
                }
			}
		}

		private int? fileStorageId = 0;
		public int? FileStorageId
		{
			get { return this.fileStorageId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.fileStorageId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("fileStorageId", this.fileStorageId);
                    this.fileStorageId = value;
                }
			}
		}

		private string wareFolder = String.Empty;
		public string WareFolder
		{
			get { return this.wareFolder; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.wareFolder != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("wareFolder", this.wareFolder);
                    this.wareFolder = value;
                }
			}
		}

		private string accountContextCode = String.Empty;
		public string AccountContextCode
		{
			get { return this.accountContextCode; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.accountContextCode != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("accountContextCode", this.accountContextCode);
                    this.accountContextCode = value;
                }
			}
		}

		private string roleCategory = String.Empty;
		public string RoleCategory
		{
			get { return this.roleCategory; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.roleCategory != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("roleCategory", this.roleCategory);
                    this.roleCategory = value;
                }
			}
		}

		private bool allow;
		public bool Allow
		{
			get { return this.allow; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.allow != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("allow", this.allow);
                    this.allow = value;
                }
			}
		}

		private string lockDomain = String.Empty;
		public string LockDomain
		{
			get { return this.lockDomain; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.lockDomain != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("lockDomain", this.lockDomain);
                    this.lockDomain = value;
                }
			}
		}

		private string templateBase = String.Empty;
		public string TemplateBase
		{
			get { return this.templateBase; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.templateBase != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("templateBase", this.templateBase);
                    this.templateBase = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		public DatabaseEntity GetDatabase()
		{
			return HostServerAccess.GetInstance().FetechEntity< DatabaseEntity >(databaseId);
		}
		public FileStorageEntity GetFileStorage()
		{
			return HostServerAccess.GetInstance().FetechEntity< FileStorageEntity >(fileStorageId);
		}
		public SiteEntity GetSite()
		{
			return HostServerAccess.GetInstance().FetechEntity< SiteEntity >(siteGuid);
		}
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static SiteWareEntity Fetch(int siteWareId)
		{
            return HostServerAccess.GetInstance().FetechEntity< SiteWareEntity >(siteWareId);
		}
		public static int Delete(int siteWareId)
		{
            return HostServerAccess.GetInstance().DeleteEntity< SiteWareEntity >(siteWareId);
		}
		
        // 根据唯一索引（UIX_SiteGuid_WareName）查找和删除实体的函数。
		public static SiteWareEntity FetchByUIX_SiteGuid_WareName(Guid siteGuid,string wareName)
		{
			string condition = "WHERE " + 
				"SiteGuid='" + siteGuid.ToString() + "'" + " AND " + 
				"WareName='" + wareName.ToString() + "'";
            return HostServerAccess.GetInstance().FindEntity< SiteWareEntity >("WHERE " + 
				"SiteGuid='" + siteGuid.ToString() + "'" + " AND " + 
				"WareName='" + wareName.ToString() + "'");
		} 
		public static int DeleteByUIX_SiteGuid_WareName(Guid siteGuid,string wareName)
		{
			string condition = "WHERE " + 
				"SiteGuid='" + siteGuid.ToString() + "'" + " AND " + 
				"WareName='" + wareName.ToString() + "'";
            return HostServerAccess.GetInstance().DeleteEntities< SiteWareEntity >("WHERE " + 
				"SiteGuid='" + siteGuid.ToString() + "'" + " AND " + 
				"WareName='" + wareName.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< SiteWareEntity > GetAllEntities()
		{
            return HostServerAccess.GetInstance().SearchEntities< SiteWareEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< SiteWareEntity > SearchEntities(string condition)
		{
            return HostServerAccess.GetInstance().SearchEntities< SiteWareEntity >(condition);
		} 
		#endregion
		
	}
}
